/**
 * f-club.cn
 * Copyright (c) 2009-2012 All Rights Reserved.
 */
package com.mjee.app.service;

import org.springframework.beans.factory.annotation.Autowired;

import com.mjee.app.mapper.ArticleCategoryMapper;
import com.mjee.app.mapper.AdminMapper;
import com.mjee.app.mapper.ArticleCommentMapper;
import com.mjee.app.mapper.ArticleMapper;
import com.mjee.app.mapper.BaseMapper;
import com.mjee.app.mapper.PermissionMapper;
import com.mjee.app.mapper.RoleMapper;
import com.mjee.app.mapper.UserDetailMapper;
import com.mjee.app.mapper.UserMapper;

/**
 * 
 * @author michael
 * @version $Id: AbstractService.java, v 0.1 2012-8-16 下午4:49:08 michael Exp $
 */
public abstract class AbstractService<TYPE> implements BaseService<TYPE> {

	@Autowired
	protected UserMapper userMapper;
	@Autowired
	protected UserDetailMapper userDetailMapper;

	@Autowired
	protected ArticleCategoryMapper articleCategoryMapper;
	@Autowired
	protected ArticleMapper articleMapper;
	@Autowired
	protected ArticleCommentMapper articleCommentMapper;
	
	@Autowired
	protected AdminMapper adminMapper;
	@Autowired
	protected RoleMapper roleMapper;
	@Autowired
	protected PermissionMapper permissionMapper;
	

	protected BaseMapper<TYPE> targetMapper;

	public AbstractService(BaseMapper<TYPE> mapper) {
		this.targetMapper = mapper;
	}

	@Override
	public int add(TYPE instance) {
		return targetMapper.insert(instance);
	}

	@Override
	public int remove(int primaryId) {
		return targetMapper.delete(primaryId);
	}

	@Override
	public int edit(TYPE instance) {
		return targetMapper.update(instance);
	}

	@Override
	public TYPE find(int primaryId) {
		return targetMapper.select(primaryId);
	}

}
